﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace IntroMongo.DAL
{
    public class MongoDBSQL
    {
        public void AddUser(string firstName, string lastName, int age)
        {
            using (var context = new MongoDBSQLDataContext())
            {
                context.AddUser(firstName, lastName, age);
            }
        }

        public void UpdateUser(int userId, string firstName, string lastName, int age)
        {
            using (var context = new MongoDBSQLDataContext())
            {
                context.UpdateUser(userId, firstName, lastName, age);
            }
        }

        public void DeleteUser(int userId)
        {
            using (var context = new MongoDBSQLDataContext())
            {
                context.DeleteUser(userId);
            }
        }

        public List<User> GetUsers(int userId)
        {
            using (var context = new MongoDBSQLDataContext())
            {
                return context.GetUsers().ToList();
            }
        }

        public User GetUserById(int userId)
        {
            using (var context = new MongoDBSQLDataContext())
            {
                return context.GetUserById(userId).FirstOrDefault();
            }
        }


        public void AddRemark(int userId, string content)
        {
            using (var context = new MongoDBSQLDataContext())
            {
                context.AddRemark(userId, content);
            }
        }

        public void UpdateRemark(int remarkId, string content)
        {
            using (var context = new MongoDBSQLDataContext())
            {
                context.UpdateRemark(remarkId, content);
            }
        }

        public void DeleteRemark(int remarkId)
        {
            using (var context = new MongoDBSQLDataContext())
            {
                context.DeleteRemark(remarkId);
            }
        }

        public List<Remark> GetRemarksByUserId(int userId)
        {
            using (var context = new MongoDBSQLDataContext())
            {
                return context.GetRemarkByUserId(userId).ToList();
            }
        }

        public Remark GetRemarkById(int remarkId)
        {
            using (var context = new MongoDBSQLDataContext())
            {
                return context.GetRemarkById(remarkId).FirstOrDefault();
            }
        }

    }
}